package com.sihan.framework.etm.common;

import java.io.Serializable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@ApiModel(value = "公共的返回布尔值的实体")
public class BooleanResultModel implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	private static final BooleanResultModel SUCCESS_RESULT = new BooleanResultModel();
	
	private static final BooleanResultModel ERROR_RESULT = new BooleanResultModel(false, "操作失败");
	
	@ApiModelProperty(value = "结果")
	private Boolean result = Boolean.TRUE;
	
	@ApiModelProperty(value = "消息")
	private String msg = "操作成功";
	
	public BooleanResultModel(boolean result, String msg) {
	    this.result = result;
	    this.msg = msg;
	  }
	
	public static BooleanResultModel ok() {
	    return SUCCESS_RESULT;
	}
	
	public static <T> BooleanResultModel failed() {
	    return ERROR_RESULT;
	}

	public static <T> BooleanResultModel failed(String message) {
	    return new BooleanResultModel(false, message);
	}
}
